package com.stars.dao.mapper.system;

import com.stars.entity.sys.SystemUserRelation;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SystemUserRelationMapper extends Mapper<SystemUserRelation> {

    /**
     * 查询此条关系是否已经存在
     *
     * @param systemUserRelation
     * @return
     * @throws Exception
     */
    SystemUserRelation findByRelationIdAndRoleId(SystemUserRelation systemUserRelation) throws Exception;

    /**
     * 查询是否存在资源
     * @param roleId
     * @return
     * @throws Exception
     */
    List<SystemUserRelation> findByRoleId(@Param("roleId") String roleId) throws Exception;

    /**
     * 根据角色Id和用户id       删除关系
     *
     * @param systemUserRelation
     * @throws Exception
     */
    void deleteByRoleIdAndUserId(SystemUserRelation systemUserRelation) throws Exception;

    /**
     * 根据角色id删除该角色的所有关系
     *
     * @param roleId
     * @throws Exception
     */
    void deleteByRoleId(String roleId) throws Exception;

    /**
     *  根据用户id删除该角色的所有关系
     * @param userId
     * @throws Exception
     */
    void deleteByUserId(String userId) throws Exception;
}